package com.lepu.app.fun.my.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.app.utils.Setting;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class BeanPubContent implements Serializable {

	private static final long serialVersionUID = 8296257066916405589L;
	
	public String RefreshTime;//detial info 中数据
	
	public String TopicID;
	public String TopicTitle;//主题标题(仅供"情感交流"用)
	public String TopicDescription;//主题描述(对"月子大咖""宝宝秀"附带的媒体资源描述)
	public String TopicDetail;//主题详情(仅供"情感交流"用)
	public String TopicType;
	
	public String UserID;
	public String UserNickName;
	public String UserAvatar;
	
	public String HasFavour; //是否已赞
	public String FavourCount; //赞的数量
	public String ViewCount; //阅读数量3
	public String ReplyCount; //回复数量
	public String RecordCreateTime;  //发表时间
	public String LatestReplyTime; //最近回复时间
	
	public String CheckStatus; //审核状态
	
	public String CategoryTitle; //圈子名称
	
	public ArrayList<BeanPubContentImage> MediaList;  //图片list
	
	public String BabyBirthDate;//宝宝生日
	
	public String IsTop;// 是否置顶 0：否，1：是；
	public int IsGood;  //是否精华  0-未加精，1-加精'

	public String SortWeight;

	public static ArrayList<BeanPubContent> parseJsonData(String dataString) {
		String result = "";
		try {
			JSONObject jsonObject = new JSONObject(dataString);
			JSONObject obj1 = (JSONObject) jsonObject.get("Result");
			JSONArray dataArray = (JSONArray) obj1.get("ListInfo");
			
			result = dataArray.toString();
		} catch (JSONException e) {
			e.printStackTrace();
		}

		Gson gson = new Gson();
		ArrayList<BeanPubContent> testArraylist = gson.fromJson(result,
				new TypeToken<List<BeanPubContent>>() {
				}.getType());
		return testArraylist;
	}
	
	public static BeanPubContent parseJson(String dataString){
		String result = "";
		try {
			JSONObject jsonObject = new JSONObject(dataString);
			JSONObject obj1 = (JSONObject) jsonObject.get("Result");
			JSONObject obj2 = (JSONObject) obj1.get("DetailInfo");
			
			result = obj2.toString();
		} catch (JSONException e) {
			e.printStackTrace();
		}
		
		Gson gson = new Gson();
		BeanPubContent item = gson.fromJson(result,new TypeToken<BeanPubContent>() {}.getType());
		return item;
	}
	
	//===============
	public static ArrayList<BeanPubContent> getTestData() {
		ArrayList<BeanPubContent> HotTopicList = new ArrayList<BeanPubContent>(); //今日热帖
	
		for(int i=0;i<Setting.PAGE_SIZE;i++)
		{
			HotTopicList.add(new BeanPubContent());
		}
		return HotTopicList;
	}
}
